#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <stack>
#include <cstring>
#include <queue>
#include <cctype>
#include <iomanip>
#include <climits>
#include <array>
#include <cmath>

using i64 = signed long long int;

constexpr int N = 1E5 + 5;

i64 v[N];

struct Node {
    int l, r;
    i64 sum;
    i64 add;
} tr[N << 2];

Node operator+(Node a, Node b) {
    Node re = {a.l, b.r};
    re.sum = a.sum + b.sum;
    return re;
}

void oper(Node &u, i64 add) {
    u.sum += (u.r - u.l + 1) * add;
    u.add += add;
}

void pushup(int u) {
    tr[u] = tr[u << 1] + tr[u << 1 | 1];
}

void pushdown(int u) {
    oper(tr[u << 1], tr[u].add);
    oper(tr[u << 1 | 1], tr[u].add);
    tr[u].add = 0;
}

void build(int u, int l, int r) {
    tr[u] = {l, r};
    if (l == r) {
        tr[u].sum = v[l];
    } else {
        int mid = l + r >> 1;
        build(u << 1, l, mid), build(u << 1 | 1, mid + 1, r);
        pushup(u);
    }
}

void modify(int u, int l, int r, i64 k) {
    if (l <= tr[u].l && tr[u].r <= r) {
        oper(tr[u], k);
        return;
    }
    pushdown(u);
    int mid = tr[u].l + tr[u].r >> 1;
    if (l <= mid) {
        modify(u << 1, l, r, k);
    }
    if (r > mid) {
        modify(u << 1 | 1, l, r, k);
    }
    pushup(u);
}

Node query(int u, int l, int r) {
    if (l <= tr[u].l && tr[u].r <= r) {
        return tr[u];
    }
    pushdown(u);
    int mid = tr[u].l + tr[u].r >> 1;
    if (r <= mid) {
        return query(u << 1, l, r);
    }
    if (l > mid) {
        return query(u << 1 | 1, l, r);
    }
    return query(u << 1, l, r) + query(u << 1 | 1, l, r);
}

void out(int u) {
    if (tr[u].l == tr[u].r) {
        std::cout << tr[u].sum << " ";
        return;
    }
    out(u << 1);
    out(u << 1 | 1);
}

void out() {
    out(1);
    std::cout << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int n, m;
    std::cin >> n >> m;

    for (int i = 1; i <= n; ++i) {
        std::cin >> v[i];
    }

    build(1, 1, n);

    while (m--) {
        int op, l, r;
        i64 k;
        std::cin >> op >> l >> r;

        if (op == 1) {
            std::cin >> k;
            modify(1, l, r, k);
        } else {
            std::cout << query(1, l, r).sum << "\n";
        }
        // out();
    }

    return 0;
}